主题
生成GUID - GenerateGuid
函数简介
生成全局唯一标识符(GUID)。
接口名称
GenerateGuidDLL调用
c
long GenerateGuid(long instance, int type);参数说明
| 参数名 | 类型 | 说明 |
|---|---|---|
| instance | 长整数型 | OLAPlug对象的指针,由 CreateCOLAPlugInterFace 接口生成。 |
| type | 整数型 | 类型:0-带-的GUID如{123e4567-e89b-12d3-a456-426614174000};1-不带-的GUID如123e4567e89b12d3a456426614174000。 |
示例
SDK 调用
cpp
#include "OLAPlugServer.h"
OLAPlugServer ola;
string guid = ola.GenerateGuid(0);csharp
using OLAPlug;
var ola = new OLAPlugServer();
string guid = ola.GenerateGuid(0);python
from OLAPlugServer import OLAPlugServer
ola = OLAPlugServer()
guid = ola.GenerateGuid(0)java
import com.olaplug.OLAPlugServer;
OLAPlugServer ola = new OLAPlugServer();
String guid = ola.GenerateGuid(0);cpp
var ola = com("OlaPlug.OlaSoft")
var guid = ola.GenerateGuid(0)vbscript
Set ola = CreateObject("OlaPlug.OlaSoft")
guid = ola.GenerateGuid(0)text
.局部变量 ola, OLAPlug
ola.创建 ()
guid = ola.GenerateGuid(0)aardio
import OLAPlugServer;
var ola = OLAPlugServer();
var guid = ola.GenerateGuid(0);text
变量 ola <类型 = OLAPlugServer>
ola = 新建 OLAPlugServer
文本型 guid = ola.GenerateGuid(0)cpp
#include "OLAPlugServer.h"
OLAPlugServer ola;
std::string guid = ola.GenerateGuid(0);原生 DLL 调用
cpp
long instance = CreateCOLAPlugInterFace();
long ptr = GenerateGuid(instance, 0);
if (ptr != 0) {
char buffer[4096] = {0};
GetStringFromPtr(ptr, buffer, sizeof(buffer));
FreeStringPtr(ptr);
}csharp
using System.Runtime.InteropServices;
using System.Text;
[DllImport("OLAPlug_x64.dll", CallingConvention = CallingConvention.StdCall)]
static extern int GetStringFromPtr(long ptr, StringBuilder lpString, int size);
[DllImport("OLAPlug_x64.dll", CallingConvention = CallingConvention.StdCall)]
static extern int FreeStringPtr(long ptr);
[DllImport("OLAPlug_x64.dll", CallingConvention = CallingConvention.StdCall)]
static extern int GetStringSize(long ptr);
[DllImport("OLAPlug_x64.dll", CallingConvention = CallingConvention.StdCall)]
static extern long CreateCOLAPlugInterFace();
[DllImport("OLAPlug_x64.dll", CallingConvention = CallingConvention.StdCall)]
static extern long GenerateGuid(long ola, int type);
long instance = CreateCOLAPlugInterFace();
long ptr = GenerateGuid(instance, 0);
if (ptr != 0) {
StringBuilder sb = new StringBuilder(GetStringSize(ptr) + 1);
GetStringFromPtr(ptr, sb, sb.Capacity);
FreeStringPtr(ptr);
string guid = sb.ToString();
}python
from ctypes import CDLL, c_int, c_int64
ola = CDLL("OLAPlug_x64.dll")
ola.CreateCOLAPlugInterFace.restype = c_int64
instance = ola.CreateCOLAPlugInterFace()
ptr = ola.GenerateGuid(instance, 0)返回值
| 返回值 | 说明 |
|---|---|
非 0 | 成功,返回 GUID字符串的指针。 |
0 | 失败。 |
